<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%@ taglib uri="/WEB-INF/tld/security.tld" prefix="s" %>
<html>
<script type="text/javascript" src="js/utils.js"></script>
<LINK REL="StyleSheet" HREF="css/style.css" TYPE="text/css" />
<LINK REL="StyleSheet" HREF="css/principal.css" TYPE="text/css" />
<script type="text/javascript" src="js/calendar/PopupWindow.js"></script>
<script type="text/javascript" src="js/calendar/CalendarPopup.js"></script>
<script type="text/javascript" src="js/calendar/AnchorPosition.js"></script>
<script type="text/javascript" src="js/calendar/date.js"></script>
<script type="text/javascript">
		var calFechaInicio = new CalendarPopup("div_fechaInicio");
		calFechaInicio.showNavigationDropdowns();
		calFechaInicio.setCssPrefix("TEST");
		calFechaInicio.setYearSelectStartOffset(80);
		function openCalendar(dateField){calFechaInicio.select(dateField,'img_FechaInicio','dd/MM/yyyy'); 
			return false;
		}
		
		var calFechaFin = new CalendarPopup("div_fechaFin");
		calFechaFin.showNavigationDropdowns();
		calFechaFin.setCssPrefix("TEST");
		calFechaFin.setYearSelectStartOffset(80);
		function openCalendar(dateField){calFechaFin.select(dateField,'img_FechaFin','dd/MM/yyyy'); 
			return false;
		}

   		function submitPlantQuery(form, orderField, orderType){
   			form.orderField.value = orderField;
   			form.orderType.value = orderType;
   			form.action = "bushelPriceList.do";
   			if (validSubmit){
   				form.submit();
   			} else {
   				alert('<fmt:message key="warning.message.common.processing"/>');
   			}
   		}
</script>
<DIV ID="div_fechaInicio"
	STYLE="position:absolute;visibility:hidden;background-color:white;layer-background-color:white;"></DIV>
<DIV ID="div_fechaFin"
	STYLE="position:absolute;visibility:hidden;background-color:white;layer-background-color:white;"></DIV>
<html:form action="/bushelPriceList" method="POST">
	<html:hidden property="orderField"/>
	<html:hidden property="orderType"/>

<table align="center" width="250" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
	<tr>	
		<td class="titulocolumna" align="center" colspan="2">			
			<bean:message key="menu.module.corn.bushel.price"/>												
		</td>
	</tr>
	
	<tr>	
		<td class="etiqueta"><bean:message key="label.program.purchase.initdate"/> </td>
		<td class="etiqueta_campo" style="text-align: right;"> 								
			<html:text readonly="true" name="BushelPriceForm" property="bushelPriceView.initDate" styleId="bushelPriceView.initDate" size="20" styleClass="columnanumero" style="width:110px" />
			<a href="javascript:var obj_dummy = openCalendar(document.getElementById('bushelPriceView.initDate'));" class="pointerhand" NAME="img_FechaInicio" ID="img_FechaInicio">
				<img id="fechatrigger" src="images/calendar.gif" border="0" />
			</a> 
		</td>
	</tr>
	
	<tr>	
		<td class="etiqueta"><bean:message key="label.program.purchase.finishdate"/> </td>
		<td class="etiqueta_campo" style="text-align: right;">		
			<html:text readonly="true" name="BushelPriceForm" property="bushelPriceView.endDate" styleId="bushelPriceView.endDate" size="20" styleClass="columnanumero" style="width:110px"  />
			<a href="javascript:var obj_dummy = openCalendar(document.getElementById('bushelPriceView.endDate'));" class="pointerhand" NAME="img_FechaFin" ID="img_FechaFin">
				<img id="fechatrigger" src="images/calendar.gif" border="0" />
			</a>   
		</td>
	</tr>
	
	<tr>
		<td colspan="2" align="right" class="columnadatoPar">						
			<html:submit styleClass="boton" property="backButton"> <bean:message key="label.common.query"/> </html:submit>
		</td>
	</tr>		
</table>	
</html:form>
<table align="center" width="440" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
	<tr>	
		<td class="titulocolumna" align="center" width="15">			
			<html:link action="/goToBushelPriceAdd.do"><img alt="<bean:message key="label.bushelprice.add"/> <bean:message key="label.plants.name"/>" src="images/nuevo.gif" border="0"></html:link>													
		</td>
		<td class="titulocolumna" align="center" width="100">
			<a href="#>" onclick="return submitPlantQuery(document.BushelPriceForm, 0, '<c:choose><c:when test="${previousOrderField == 0 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.bushelprice.fecha"/>
				<c:choose>
					<c:when test="${previousOrderField == 0 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 0 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>	
		</td>
		<td class="titulocolumna" align="center" width="100">
			<a href="#>" onclick="return submitPlantQuery(document.BushelPriceForm, 1, '<c:choose><c:when test="${previousOrderField == 1 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.purchaseorder.version.period"/>
				<c:choose>
					<c:when test="${previousOrderField == 1 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 1 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>
		</td>
		<td class="titulocolumna" align="center" width="100">
			<a href="#>" onclick="return submitPlantQuery(document.BushelPriceForm, 2, '<c:choose><c:when test="${previousOrderField == 2 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.creditline.balance.amount"/>
				<c:choose>
					<c:when test="${previousOrderField == 2 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 2 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>	
		</td>						
	</tr>
	<logic:notEmpty name="bushelPriceList">
		<logic:iterate id="row" name="bushelPriceList" indexId="int_i">
			<tr class="<%=((int_i.intValue()%2)==0?"columnadatoPar":"columnadatoNon")%>">							
				<td align="center">					
					<html:link action="/goToPriceEdit.do" paramId="bushelId" paramName="row" paramProperty="bushelId"> <img alt="<bean:message key="label.bushelprice.edit"/> <bean:write name="row" property="bushelId"/>" src="images/modificar.gif" border="0"> </html:link>					
				</td>							
				<td align="center"><bean:write name="row" property="date"/></td>
				<td align="center"><bean:write   name="row" property="monthPeriodId"/></td>				
				<td align="right"><bean:write  name="row" property="amount"/></td>								
			</tr>
		</logic:iterate>
	</logic:notEmpty>
</table>
<br />
<br />	
